﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Routing;
using DAL;
using System.Web.Compilation;
using System.Web.UI;

/// <summary>
/// Summary description for CostHandler
/// </summary>
public class CostHandler : IRouteHandler
{
    public CostHandler()
    {
        //
        // TODO: Add constructor logic here
        //
    }
    public IHttpHandler GetHttpHandler(RequestContext requestContext)
    {
        try
        {
            string strdata = requestContext.RouteData.Values["data"] as string;
            string[] arrdata = strdata.Split('_');
            switch (arrdata[0])
            {
                case "cost": return BuildManager.CreateInstanceFromVirtualPath("~/Category/ChiPhi.aspx", typeof(Page)) as Page;               
                case "ncost": return BuildManager.CreateInstanceFromVirtualPath("~/Cost/NhapChiPhi.aspx", typeof(Page)) as Page;
                case "calcp": return BuildManager.CreateInstanceFromVirtualPath("~/Cost/ChiPhiNhapHang.aspx", typeof(Page)) as Page;
                case "cpinse": return BuildManager.CreateInstanceFromVirtualPath("~/Cost/NhapChiPhi_TraCuu.aspx", typeof(Page)) as Page;
                case "cpse": return BuildManager.CreateInstanceFromVirtualPath("~/Cost/ChiPhiNhapHang_TraCuu.aspx", typeof(Page)) as Page;
                case "cp":
                    {
                        string masterid = arrdata[1];
                        HttpContext.Current.Items["masterid"] = masterid;
                        return BuildManager.CreateInstanceFromVirtualPath("~/Cost/ChiPhiNhapHang_View.aspx", typeof(Page)) as Page;
                    }
                case "cprpt":
                    {
                        string masterid = arrdata[1];
                        HttpContext.Current.Items["masterid"] = masterid;
                        return BuildManager.CreateInstanceFromVirtualPath("~/Cost/XuatBaoCao.aspx", typeof(Page)) as Page;
                    }
                case "cpin":
                    {
                        string masterid = arrdata[1];
                        HttpContext.Current.Items["masterid"] = masterid;
                        return BuildManager.CreateInstanceFromVirtualPath("~/Cost/NhapChiPhi_View.aspx", typeof(Page)) as Page;
                    }
                default:
                    {
                        return BuildManager.CreateInstanceFromVirtualPath("~/Cost/NhapChiPhi.aspx", typeof(Page)) as Page;

                    }

            }

        }
        catch
        {
            return null;
        }

    }
}